//
//  ServerMng.m
//  habit
//
//  Created by huck on 15-9-2.
//  Copyright (c) 2015年 custom. All rights reserved.
//

#import "ServerMng.h"
#import "HttpRequest.h"
#import "AppDelegate.h"
#import "BaseNavigationController.h"
#import "Config.h"
#import "DateUtil.h"

#import "LoginViewController.h"
#import "MainViewController.h"


@interface ServerMng()<UIAlertViewDelegate>

@end

@implementation ServerMng

@synthesize netType,networkEnabled,loginUser;

- (id)init
{
    self = [super init];
    if (self) {
        _saveArray = [NSMutableArray array];
        _showSavearray = NO;
    }
    return self;
}

+ (ServerMng *)sharedServerMng
{
    static ServerMng *serverMng = nil;
    static dispatch_once_t pred = 0;
    dispatch_once(&pred, ^{
        serverMng = [[self alloc] init];
    });
    return serverMng;
}

- (void)initMainWindow
{
    UIViewController *controller  = [[MainViewController alloc] init];

    BaseNavigationController *navController = [AppUtils getRootNavigationController];
    [navController setViewControllers:[NSArray arrayWithObject:controller] animated:YES];
}
//
- (void)initLoginWindow:(BOOL)backAnim
{
    LoginViewController *controller = controller = [[LoginViewController alloc] init];
    BaseNavigationController *navController = [AppUtils getRootNavigationController];
    
    if (backAnim) {
        CATransition *animation = [CATransition animation];
        animation.duration = 0.3;
        animation.timingFunction = UIViewAnimationCurveEaseInOut;
        animation.type = kCATransitionReveal;
        animation.subtype = kCATransitionFromLeft;
        [[AppUtils getAppDelegate].window.layer addAnimation:animation forKey:nil];
    }
    [navController setViewControllers:[NSArray arrayWithObject:controller] animated:NO];
}



@end
